fix: refresh external secrets before secret use#188
Merged
vigneshrajsb merged 2 commits intomainfrom Apr 28, 2026
Merged
Conversation
vmelikyan
approved these changes
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This fixes native secret reference handling so each build or redeploy waits on the latest External Secrets Operator reconciliation before using the synced Kubernetes Secret.
Changes:
ExternalSecretresources using the documentedforce-syncannotation.target.deletionPolicy: Mergeso provider-side deletions remove stale keys from the target Secret instead of retaining old values.Why
Previously, reapplying the same
ExternalSecretmanifest could leave a build or redeploy using stale Secret data until the configured refresh interval elapsed. Waiting only for key existence was also not enough because an old target Secret could already contain the requested key.With this change, each processing run changes the ExternalSecret metadata, the operator reconciles immediately, and Lifecycle waits until the target Secret reflects that same run.
Validation
pnpm run lintpnpm exec tsc --project tsconfig.server.json --noEmit --pretty falsepnpm exec jest --runTestsByPath src/server/lib/kubernetes/__tests__/externalSecret.test.ts src/server/services/__tests__/secretProcessor.test.ts src/server/lib/agentSession/__tests__/forwardedEnv.test.ts --runInBandpnpm run testNote:
pnpm run ts-checkcurrently fails on existing repo-wide TypeScript errors in generated Next.js types, helper scripts, and unrelated API/service files. The changed server project passestsconfig.server.json.References
force-sync.deletionPolicy: Mergeas removing deleted provider keys from the target Secret while leaving the Secret resource in place.